package day11;


import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

public class A3 {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        A4();
    }
    static void A3(){
        System.out.println("请输入小王的生日(yyyy-MM-dd):");
        String a = sc.nextLine();
        System.out.println("请输入小李的生日(yyyy-MM-dd):");
        String b = sc.nextLine();
        LocalDate time = LocalDate.parse(a);
        LocalDate time2 = LocalDate.parse(b);
        int years = time.until(time2).getYears();
        int months = time.until(time2).getMonths();
        int days = time.until(time2).getDays();
        System.out.println("相差: " + years + "年 " + months + "个月 " + days + "天");
    }
    static void B4(){
        System.out.println("请输入一个日期(yyyy-MM-dd):");
        String a = sc.nextLine();
        LocalDate time = LocalDate.parse(a);
        time = time.with(DayOfWeek.MONDAY);
        System.out.println("请输入要查询的星期:");
        int n = sc.nextInt();
        time = time.plusDays(n-1);
        System.out.println(time);
    }

    static void C5(){
        boolean call = false;
        LocalTime time= LocalTime.of(00,00,00);
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
        System.out.println("开始通话");
        while (true){
            System.out.println("是否继续通话y/n");
            String a = sc.next();
            if (a.equals("y")) {
                time = time.plusMinutes(10);
                System.out.println("已经通话:"+time.format(formatter));
                call = true;
            }
            else if (a.equals("n")) {
                if (!call) {
                    System.out.println("未使用电话");
                }
                else {
                    System.out.println("已经通话:"+time.format(formatter));
                    return;
                }
            }
        }
    }

    static void A4(){
        System.out.println("请输入年月(yyyy-MM):");
        String day = sc.nextLine();
        day = day+"-01";
        LocalDate time = LocalDate.parse(day);
        int days = time.lengthOfMonth();
        int n = time.getDayOfWeek().getValue();
        System.out.println("一"+"\t"+"二"+"\t"+"三"+"\t"+"四"+"\t"+"五"+"\t"+"六"+"\t"+"日");
        //\033[31m 红色
        //\033[32m 绿色
        //\033[33m 黄
        //\033[34m 蓝色
        //\033[0m 黑色
        System.out.print("\033[34m");
        for (int j=1;j<=days+n-1;j++){
            if(j<=n-1){
                System.out.print("\t");
            }
            else {
                System.out.print(j-n+1);
                System.out.print("\t");
            }
            if(j%7==0){
                System.out.println(" ");
            }
        }
    }
}
